﻿using System;
using System.Collections.Generic;
using UnityEngine;
using Yoozoo.Framework.Core;
using Yoozoo.Gta.Common;

namespace Gameplay.PVE.Survivor
{
    public class TestManager: BattleSingleton<TestManager>
    {
        public void Initialize()
        {
            
        }

        public void Update()
        {
            
        }

        private bool showhierarchy;
        
        public void TestStart()
        {
            ResidentHandler.Inst.GetFunction("L_SurvivorManager.OpenTestUI").Action();
            AddTestButton("刷怪", () =>
            {
                //BattleDebug.LogError("刷怪");
                /*for (int i = 0; i < 1; i++)
                {
                    var groupId = SurvivorManager.testSpawnGroupId;
                    if (groupId == 0)
                    {
                        groupId = 4;
                    }
                    BattleEventManager.Instance.FixedSpawn(1,groupId,BattleHelper.GetRandomPoint());
                }*/
                var groupId = SurvivorManager.testSpawnGroupId;
                if (groupId == 0)
                {
                    groupId = 53008;
                }
                StageManager.Instance.SpawnSingleEnemy(groupId,BattleHelper.GetRandomPoint(),Vector3.forward,EEnemyAIType.SearchAllMap);
            });
            AddTestButton("免伤", () =>
            {
                BattleDebug.LogError("免伤");
                SurvivorManager.isNoDamage = !SurvivorManager.isNoDamage;
            });
            AddTestButton("己方免伤", () =>
            {
                BattleDebug.LogError("免伤");
                SurvivorManager.selfNoDamage = !SurvivorManager.selfNoDamage;
            });
            AddTestButton("掉落", () =>
            {
                BattlePropsManager.Instance.CreateDropDollar(StageManager.Instance.TeamGroup.Position,Vector3.forward,1);
            });
            AddTestButton("胜利", () =>
            {
                SurvivorManager.Instance.Win();
            });
            /*AddTestButton("渲染", () =>
            {
                BattleDebug.LogError("渲染");
                SurvivorManager.isUnitRendering = !SurvivorManager.isUnitRendering;
                UnitManager.Instance.SetRenderEnabled(SurvivorManager.isUnitRendering);
            });
            AddTestButton("寻路", () =>
            {
                BattleDebug.LogError("寻路");
                SurvivorManager.isNavmeshActive = !SurvivorManager.isNavmeshActive;
                UnitManager.Instance.SetNavmeshEnabled(SurvivorManager.isNavmeshActive);
            });
            AddTestButton("失败", () =>
            {
                SurvivorManager.Instance.Lose();
            });*/
            AddTestButton("Mp", () =>
            {
                StageManager.Instance.TeamGroup.SetMpMax();
            });
            AddTestButton("敌人Mp", () =>
            {
                UnitManager.Instance.EnemyMpMax();
            });
            AddTestButton("Hierarchy", () =>
            {
                if (!showhierarchy)
                {
                    ResidentHandler.Inst.GetFunction("pveManager.showHierarchyUI").Call();
                }
                else
                {
                    ResidentHandler.Inst.GetFunction("pveManager.hideHierarchyUI").Call();
                }
                showhierarchy = !showhierarchy;
            });
            AddTestButton("RPG", () =>
            {
                SurvivorManager.Instance.SwitchToRpg(301003);
            });
            AddTestButton("牛逼", () =>
            {
                SurvivorManager.selfDamageUp =! SurvivorManager.selfDamageUp;
            });
            /*AddTestButton("碰撞", () =>
            {
                BattleDebug.LogError("碰撞");
                MapManager.Instance.AddCollider();
            });*/
        }

        public void AddTestButton(string title, Action action)
        {
            ResidentHandler.Inst.GetFunction("L_SurvivorManager.AddTestButton").Action(title, action);
        }

        public void UpdateTestLabel(string key, string value)
        {
            ResidentHandler.Inst.GetFunction("L_SurvivorManager.UpdateTestText").Action(key,value);
        }
    }
}
